{extend name="top/index" /}
{block name="main"}
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<style>
		.select2-container--open {
 
		 z-index: 9999999 !important;
		 
		}
	</style>
	<div class="page-content-wrapper">
		<div class="page-content" style=" min-height: 700px;">
			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
							<h4 class="modal-title">Modal title</h4>
						</div>
						<div class="modal-body">
							 Widget settings form goes here
						</div>
						<div class="modal-footer">
							<button type="button" class="btn blue">Save changes</button>
							<button type="button" class="btn default" data-dismiss="modal">Close</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
			<!-- /.modal -->
			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<!-- BEGIN STYLE CUSTOMIZER -->
			
			<!-- END STYLE CUSTOMIZER -->
			<!-- BEGIN PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					<h3 class="page-title">
					账户管理 <!-- <small>view order details</small> -->
					</h3>
					<ul class="page-breadcrumb breadcrumb">
						
						<li>
							<i class="fa fa-home"></i>
							<a href="{:url('index/index/index')}">
								Home
							</a>
							<i class="fa fa-angle-right"></i>
						</li>
						<li>
							<a href="{:url('index/manage/index')}">
								账户管理
							</a>
							<i class="fa fa-angle-right"></i>
						</li>
						
					</ul>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">
					<!-- Begin: life time stats -->
					<div class="portlet">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-shopping-cart"></i>账户管理
								<!-- <span class="hidden-480">
									 | Dec 27, 2013 7:16:25
								</span> -->
							</div>
							<!-- <div class="actions">
								<a href="#" class="btn default yellow-stripe">
									<i class="fa fa-angle-left"></i>
									<span class="hidden-480">
										 Back
									</span>
								</a>
								<div class="btn-group">
									<a class="btn default yellow-stripe" href="#" data-toggle="dropdown">
										<i class="fa fa-cog"></i>
										<span class="hidden-480">
											 Tools
										</span>
										<i class="fa fa-angle-down"></i>
									</a>
									<ul class="dropdown-menu pull-right">
										<li>
											<a href="#">
												 Export to Excel
											</a>
										</li>
										<li>
											<a href="#">
												 Export to CSV
											</a>
										</li>
										<li>
											<a href="#">
												 Export to XML
											</a>
										</li>
										<li class="divider">
										</li>
										<li>
											<a href="#">
												 Print Invoice
											</a>
										</li>
									</ul>
								</div>
							</div> -->
						</div>
						<div class="portlet-body">
							<div class="portlet blue box" style="float: left;width: 25%;">
															<div class="portlet-title">
																<div class="caption">
																	<i class="fa fa-cogs"></i>组织架构
																</div>
																<div class="tools">
																	<a href="javascript:;" class="reload">
																	</a>
																</div>
															</div>
															<div class="portlet-body" >
																<div id="tree_1" class="tree-demo" >
																	{$tree}
																</div>
															</div>
														</div>
								<div class="tab-content">
							<div class="tabbable" style="float: right;width: 70%;">
								<ul class="nav nav-tabs nav-tabs-lg">
									<li class="active">
										<a href="#tab_1" data-toggle="tab">
											 人员
										</a>
									</li>
									<li>
										<a href="#tab_2" data-toggle="tab">
											 部门
											<!-- <span class="badge badge-success">
												 4
											</span> -->
										</a>
									</li>
									
									<li>
										<a href="#tab_3" data-toggle="tab">
											 授权
											<!-- <span class="badge badge-danger">
												 2
											</span> -->
										</a>
									</li>
									
								</ul>
							</div>
														
													<div class="tab-pane active" id="tab_1">
														<div class="table-container" style="float: right;width: 70%;">
															<div  style="float: right;"> 
																<a href="{:url('ryadd')}" class="btn btn-success btn-sm"><i class="glyphicon glyphicon-plus"></i>人员</a>
															</div>
															<table class="table table-striped table-bordered table-hover" id="datatable_shipment">
															<thead>
															<tr role="row" class="heading">
																<th width="15%">
																	 用户名&nbsp;#
																</th>
																<th width="15%">
																	 部门
																</th>
																<th width="30%">
																	 权限
																</th>
																<th width="15%">
																	 操作
																</th>
															</tr>

															{if empty($renyuan)} 
															<tr role="row" class="filter">
																
																<td colspan="4">没有人员信息</td>
															</tr>

															{else /}
															{volist name="renyuan" id="aa"}
															<tr role="row" class="filter">
																
																<td>
																	{$aa.user_name}
																</td>
																<td>
																	{$aa.org_name}
																</td>
																<td>
																	{$aa.chara_name}
																</td>
																<td >
																	<a href="{:url('ryedit',['id'=>$aa['user_id']])}" class="btn btn-warning btn">编辑</a>
																	<!-- <a href="{:url('rydel',['id'=>$aa['user_id']])}" class="btn btn-danger btn ">删除</a> -->
																	{if $aa.is_delete == '0'}
																	<button class="btn btn-danger" data-href="{:url('rydel',['id'=>$aa['user_id']])}" data-toggle="modal" data-target="#confirm-deletery">
																		禁用 
																	</button>
																	{else/}
																	<button class="btn btn-success" data-href="{:url('ryactive',['id'=>$aa['user_id']])}" data-toggle="modal" data-target="#confirm-active">
																		激活 
																	</button>
																	{/if}
																</td>
															</tr>
															{/volist}
															{/if}
															</thead>
															</table>
															<div style="float: right;">
															</div>
															<!-- 删除人员的模态框 -->
													<div class="modal fade" id="confirm-deletery" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
													<div class="modal-dialog">
													<div class="modal-content">
													<div class="modal-header">
													请确认
													</div>
													<div class="modal-body">
													确认禁用该人员吗？
													</div>
													<div class="modal-footer">
													<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
													<a class="btn btn-danger btn-okry">禁用人员</a>
													</div>
													</div>
													</div>
													</div>
													
													<script>
														$('#confirm-deletery').on('show.bs.modal', function(e) {
														$(this).find('.btn-okry').attr('href', $(e.relatedTarget).data('href'));
														});
													</script>
												<!--  -->
												<!-- 激活人员的模态框 -->
													<div class="modal fade" id="confirm-active" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
													<div class="modal-dialog">
													<div class="modal-content">
													<div class="modal-header">
													请确认
													</div>
													<div class="modal-body">
													确认激活该人员吗？
													</div>
													<div class="modal-footer">
													<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
													<a class="btn btn-danger btn-active">激活人员</a>
													</div>
													</div>
													</div>
													</div>
													
													<script>
														$('#confirm-active').on('show.bs.modal', function(e) {
														$(this).find('.btn-active').attr('href', $(e.relatedTarget).data('href'));
														});
													</script>
												<!--  -->
														</div>
													</div>
													<div class="tab-pane" id="tab_2">
														<!-- <div class="portlet blue box" style="float: left;width: 25%;">
															<div class="portlet-title">
																<div class="caption">
																	<i class="fa fa-cogs"></i>组织架构
																</div>
																<div class="tools">
																	<a href="javascript:;" class="reload">
																	</a>
																</div>
															</div>
															<div class="portlet-body" >
																<div id="tree_1" class="tree-demo" >
																	{$tree}
																</div>
															</div>
														</div> -->
														<div class="table-container" style="float: right;width: 70%;">
															<div  style="float: right;"> 
															<a href="{:url('bmadd')}" class="btn btn-success btn-sm"><i class="glyphicon glyphicon-plus"></i>部门</a>
															</div>
															<table class="table table-striped table-bordered table-hover" id="datatable_shipment">
															<thead>
															<tr role="row" class="heading">
																<th width="15%">
																	 类型&nbsp;#
																</th>
																<th width="15%">
																	 部门
																</th>
																<!-- <th width="15%">
																	人数
																</th> -->
																<th width="15%">
																	 操作
																</th>
															</tr>
																</tr role="row" class="filter">
																{if empty($bumen)} 
																<tr role="row" class="filter">
																	
																	<td colspan="4">没有部门信息</td>
																</tr>
																{else /}
																{volist name="bumen" id="vo"}
																<tr role="row" class="filter">
																	<!-- <td>
																		<input type="checkbox" class="group-checkable" id="{$vo.org_id}">
																	</td> -->
																		{if condition="($vo.org_type == 0)"} <td>中心机关</td>
															            {elseif condition="$vo.org_type eq 1"/}<td>基层单位</td>
															            {/if}
																	<td>
																		<a style="text-decoration: none;" href="{:url('sonindex',['id'=>$vo['org_id']])}">{$vo.org_name}</a>
																	</td>
																
																	<td>
																		<!-- <button class="btn btn-danger btn del-btn" data-id="">编辑</button> -->
																		<a href="{:url('bmedit',['id'=>$vo['org_id']])}" class="btn btn-primary btn">编辑</a>
																		<!-- <a href="{:url('bmdel',['id'=>$vo['org_id']])}" class="btn btn-warning btn">删除</a> -->
																		<button class="btn btn-danger" data-href="{:url('bmdel',['id'=>$vo['org_id']])}" data-toggle="modal" data-target="#confirm-delete">
																		删除部门 
																		</button>
																	</td>
																</tr>
																{/volist}
																{/if}
																</div>
								<!-- 删除部门的模态框 -->
									<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
									<div class="modal-dialog">
									<div class="modal-content">
									<div class="modal-header">
									请确认
									</div>
									<div class="modal-body">
									确认删除该部门吗？
									</div>
									<div class="modal-footer">
									<button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
									<a class="btn btn-danger btn-ok">删除部门</a>
									</div>
									</div>
									</div>
									</div>
									
									<script>
										$('#confirm-delete').on('show.bs.modal', function(e) {
										$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
										});
									</script>
								<!--  -->
															</thead>
															<tbody>
															</tbody>
															</table>
														</div>
													</div>
													
													<div class="tab-pane" id="tab_3">
														<!-- <div class="portlet blue box" style="float: left;width: 25%;">
															<div class="portlet-title">
																<div class="caption">
																	<i class="fa fa-cogs"></i>组织架构
																</div>
																<div class="tools">
																	<a href="javascript:;" class="reload">
																	</a>
																</div>
															</div>
															<div class="portlet-body" >
																<div id="tree_1" class="tree-demo" >
																	{$tree}
																</div>
															</div>
														</div> -->
														<div class="table-container" style="float: right;width: 70%;">
															<button class="btn btn-success btn-sm " data-toggle="modal" data-target="#myModal" style="float: right;">
																<i class="glyphicon glyphicon-plus"></i>授权
															</button>
															<table class="table table-striped table-bordered table-hover" id="datatable_shipment">
															<thead>
															<tr role="row" class="heading">
																<th width="20%">
																	 权限&nbsp;#
																</th>
																<th width="80%">
																	 人员
																</th>
																
																{volist name="all" id="vo"}
																<tr role="row" class="filter">
																	<td>{$vo.chara_name}</td>
																	<td>{$vo.user_name}</td>
																{/volist}
																</tr>
															</thead>
															<tbody>
															</tbody>
															</table>
															<!-- 模态框（Modal） -->
															<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
																<div class="modal-dialog">
																	<div class="modal-content">
																		<div class="modal-header">
																			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
																				&times;
																			</button>
																			<h4 class="modal-title" id="myModalLabel">
																				授权
																			</h4>
																		</div>
																		
																		<div class="modal-body">
																			<div class="form-group">
																			<label class="col-sm-2 control-label">人员:</label>
																			    <select id="use" style="width: 400px;" multiple="multiple" class="form-control-static col-sm-10">
																			        {volist name='use' id='user'}
																						<option> {$user}</option>
																					{/volist}

																			    </select>
																			</div>

																			<div class="form-group">
																			    <label class="col-sm-2 control-label">权限:</label>
																				   <!-- <select class="form-control-static col-sm-10" name="cha" id="cha"> -->
																					{volist name='cha' id='char'}
																					<div style="float: left;">
																					<input type="checkbox" name="cha" id="cha" value="{$char.chara_id}">{$char.chara_name}
																					</div>
																					{/volist}
																					<!-- </select> -->
																			</div>
																			<br>
																		</div>
																		<div class="modal-footer">
																			<button type="button" class="btn btn-warning close-btn" data-dismiss="modal">关闭
																			</button>
																				<input type="submit" class="btn btn-primary sub-btn" value="授权"/>
																		</div>
																	</div><!-- /.modal-content -->
																</div><!-- /.modal -->
														</div>
													</div>
													
												</div>
											</div>
										</div>
									</div>
									<!-- End: life time stats -->
								</div>
							</div>
							<!-- END PAGE CONTENT-->
						</div>
					</div>
					<!-- END CONTENT -->
				</div>
				<!-- END CONTAINER -->
				<!-- BEGIN FOOTER -->
				<div class="footer">
					<div class="footer-inner">
						 2018 &copy; 仁聚科技
					</div>
					<div class="footer-tools">
						<span class="go-top">
							<i class="fa fa-angle-up"></i>
						</span>
					</div>
				</div>
				<!-- END FOOTER -->
				<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
				<!-- BEGIN CORE PLUGINS -->
				<!--[if lt IE 9]>
    <script src="assets/plugins/respond.min.js"></script>
    <script src="assets/plugins/excanvas.min.js"></script> 
    <![endif]-->
				<script src="/static/assets/plugins/jstree/dist/jstree.min.js"></script>
				<script src="/static/assets/scripts/custom/ui-tree.js"></script>
				<script src="/static/assets/scripts/core/app.js"></script>
				<link rel="stylesheet" type="text/css" href="/static/assets/plugins/jstree/dist/themes/default/style.min.css"/>
				<script src="/static/assets/scripts/core/dt.js"></script>
				<script src="/static/assets/js/toastr.min.js" rel="stylesheet"/></script>
				<link href="/static/assets/css/toastr.min.css" rel="stylesheet"/>
				<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
				<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
				<!-- END PAGE LEVEL SCRIPTS -->
<script type="text/javascript">

    $(document).ready(function() {
        $("#use").select2();
    });


</script>

	
<script>
    dt().getModals();
    dt().getUrl();
    
    jQuery(document).ready(function() {
        App.init();
        UITree.init();
        var url = '{:url(\'index/Manage/index\')}';
        
        $("#tree_1").on('changed.jstree', function (e, data) {
            var id = data.node.data.id;
            // console.log(id);
            $.ajax({
                url:'{:url(\'index/common/setOrg_Id\')}',
                data:{org_id:id},
                type:'post',
                dataType:'json',
                success:function (c) {
                    // if(e.code ==1) {
                    //     window.location.href = url;
                    // }
                    
                }
            });
        });

        $("#tree_1").on('changed.jstree', function (e, data) {
            var id = data.node.data.id;
            // console.log(id);
            $.ajax({
                url:'{:url(\'index/manage/treeindex\')}',
                data:{id:id},
                type:'post',
                // dataType:'json',
                success:function (e) {
                    // if(e.code ==1) {
					window.location.href = "/index/manage/sonindex/id/"+id+".html";
                        // window.location.href = url;
                    // }
                    
                }
            });
        });
    });
</script>
    <script type="text/javascript">
  // 获取cha use的值
  $(function(){
    	 var checkID = [];//定义一个空数组
    $('.sub-btn').click(function () {
         $("input[name='cha']:checked").each(function(i){ //把所有被选中的复选框的值存入数组
             checkID[i] =$(this).val();
          });
      	postdata();
    });

     function postdata(){     
         //提交数据函数   
        toastr.options = {  
            closeButton: true,  
            debug: false,  
            progressBar: true,  
            positionClass: "toast-top-right",  
            onclick: null,  
            showDuration: "1000",  
            hideDuration: "1000",  
            timeOut: "1000",  
            extendedTimeOut: "1000",  
            showEasing: "swing",  
            hideEasing: "linear",  
            showMethod: "fadeIn",  
            hideMethod: "fadeOut"  
        };

        $.ajax({                                                  //调用jquery的ajax方法   
          type: "POST",                                      //设置ajax方法提交数据的形式   
          url: "sqzz",                                        
          data: {
                  cha : checkID,
                  use : $("#use").val()
              }, 
          success: function(data){    
          // console.log(data);   
          if (data) {
            toastr.success('授权成功');
            setInterval(function(){
              location.reload(true);
            }, 1000);
          }else{
            toastr.error('授权失败，请重试');
          }
        },
        error: function () {
                alert('AJAX操作失败');
            }
        });   
     }   
    })
</script>
<script>
		$(function(){
			$('.manage').addClass("active");
		});
</script>
				<!-- END JAVASCRIPTS -->
</body>
				<!-- END BODY -->
</html>
{/block}